##############################################################################
# cmake configuration file for GEAR
#
# requires:
#   MacroCheckPackageLibs.cmake for checking package libraries
#
# returns following variables:
#
#   GEAR_FOUND      : set to TRUE if GEAR found
#       if FIND_PACKAGE called with REQUIRED and COMPONENTS arguments
#       GEAR_FOUND is only set to TRUE if ALL components are also found
#       if REQUIRED is NOT set components may or may not be available
#
#   GEAR_ROOT       : path to this GEAR installation
#   GEAR_VERSION    : package version
#   GEAR_LIBRARIES  : list of GEAR libraries (NOT including COMPONENTS)
#   GEAR_INCLUDE_DIRS  : list of paths to be used with INCLUDE_DIRECTORIES
#   GEAR_LIBRARY_DIRS  : list of paths to be used with LINK_DIRECTORIES
#   GEAR_COMPONENT_LIBRARIES      : list of GEAR component libraries
#   GEAR_${COMPONENT}_FOUND       : set to TRUE or FALSE for each library
#   GEAR_${COMPONENT}_LIBRARY     : path to individual libraries
#   GEAR_${COMPONENT}_LIB_DEPENDS : individual library dependencies
#
# @author Jan Engels, Desy
##############################################################################

SET( GEAR_ROOT "@CMAKE_INSTALL_PREFIX@" )
SET( GEAR_VERSION "@GEAR_VERSION@" )


# ---------- include dirs -----------------------------------------------------
# do not store find results in cache
SET( GEAR_INCLUDE_DIRS GEAR_INCLUDE_DIRS-NOTFOUND )
MARK_AS_ADVANCED( GEAR_INCLUDE_DIRS )

FIND_PATH( GEAR_INCLUDE_DIRS
	NAMES gear/GEAR.h
	PATHS ${GEAR_ROOT}/include
	NO_DEFAULT_PATH
)

# for backwards compatibility
IF( GEAR_INCLUDE_DIRS )
    LIST( APPEND GEAR_INCLUDE_DIRS ${GEAR_INCLUDE_DIRS}/gear )
ENDIF( GEAR_INCLUDE_DIRS )



# ---------- libraries --------------------------------------------------------
INCLUDE( "@ILCSOFT_CMAKE_MODULES_ROOT@/MacroCheckPackageLibs.cmake" )

# only standard libraries should be passed as arguments to CHECK_PACKAGE_LIBS
# additional components are set by cmake in variable PKG_FIND_COMPONENTS
# first argument should be the package name
CHECK_PACKAGE_LIBS( GEAR gearsurf gear gearxml )




# ---------- dependencies -----------------------------------------------------
INCLUDE( "@ILCSOFT_CMAKE_MODULES_ROOT@/MacroExportPackageDeps.cmake" )
# exports following package dependencies (if set)
# first argument of macro should be the package name
SET( GEAR_DEPENDS_INCLUDE_DIRS  @GEAR_DEPENDS_INCLUDE_DIRS@ )
SET( GEAR_DEPENDS_LIBRARY_DIRS  @GEAR_DEPENDS_LIBRARY_DIRS@ )
SET( GEAR_DEPENDS_LIBRARIES  @GEAR_DEPENDS_LIBRARIES@ )
EXPORT_PACKAGE_DEPENDENCIES( GEAR )



# ---------- final checking ---------------------------------------------------
INCLUDE( FindPackageHandleStandardArgs )
# set GEAR_FOUND to TRUE if all listed variables are TRUE and not empty
# GEAR_COMPONENT_VARIABLES will be set if FIND_PACKAGE is called with REQUIRED argument
FIND_PACKAGE_HANDLE_STANDARD_ARGS( GEAR DEFAULT_MSG GEAR_ROOT GEAR_INCLUDE_DIRS GEAR_LIBRARIES ${GEAR_COMPONENT_VARIABLES} )

